<?php 
$errors = '';
$myemail = 'support@twingate.nl';//<-----Put Your email address here.
$name =  'Device'; //<----------- Put your Name or App name here

if(empty($_POST['email']))
{
    $errors .= "\n Error: EMAIL FIELD IS REQUIRED";
}

$email_address = $_POST['email']; 
$subject = $_POST['subject']; 
$reviveApp = $_POST['reviveApp']; 
$sourcePackageName = $_POST['packageName']; 
$sourceMainActivityName = $_POST['mainActivityPath']; 
$extraInfo = $_POST['extraInfo'];
 
$message = "reviveApp: $reviveApp \n  sourcePackageName: $sourcePackageName \n sourceMainActivityName: $sourceMainActivityName \n extraInfo: \n $extraInfo"; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
	$to = $myemail; 
	$email_subject = " [ $sourcePackageName ] : $subject ";
	$email_body = "Oops! An application has crashed: ".
	" Here are the details:\n\n Name: $name \n\n Email: $email_address \n\n Message \n\n\n $message"; 
	
	$headers = "From: $myemail\n"; 
	$headers .= "Reply-To: $email_address";
	
	mail($to,$email_subject,$email_body,$headers);
	//redirect to the 'thank you' page
	header('Location: contact-form-thank-you.html');
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>


</body>
</html>